import { ApiProperty } from '@nestjs/swagger';
import { Exclude, Expose, Transform, Type } from 'class-transformer';

// 精简的用户信息DTO，仅用于评论回复响应
class UserInfo {
  @ApiProperty({ description: '用户ID' })
  id: string;

  @ApiProperty({ description: '用户名' })
  username: string;

  @ApiProperty({ description: '用户邮箱' })
  email: string;

  @ApiProperty({ description: '用户头像URL', required: false })
  avatar?: string;
}

/**
 * 评论回复响应DTO
 */
@Exclude()
export class CommentReplyResponseDto {
  @Expose()
  @ApiProperty({ description: '回复ID' })
  id: string;

  @Expose()
  @ApiProperty({ description: '回复内容' })
  content: string;

  @Expose()
  @ApiProperty({ description: '关联的评论ID' })
  commentId: string;

  @Expose()
  @ApiProperty({ description: '回复用户ID' })
  userId: string;

  @Expose()
  @Type(() => UserInfo)
  @ApiProperty({ description: '回复用户信息', type: UserInfo })
  user: UserInfo;

  @Expose()
  @ApiProperty({ description: '创建时间' })
  @Transform(({ value }) => value && new Date(value).toISOString())
  createdAt: Date;

  @Expose()
  @ApiProperty({ description: '更新时间' })
  @Transform(({ value }) => value && new Date(value).toISOString())
  updatedAt: Date;
} 